import javax.sql.StatementEventListener;
import java.util.*;

public class Test4 {


    // 杨辉三角
    public static void main03(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            Stack<LinkedList<Integer>> stack=new Stack<>();
            int m=0;
            while(m<n){
                LinkedList<Integer> list=new LinkedList<>();
                list.add(1);
                if(!stack.empty()){
                    LinkedList<Integer> pernode= stack.peek();
                    int k=1;
                    while(k<m){
                        list.add(pernode.get(k)+ pernode.get(k-1));
                        k++;
                    }
                    // 每一行最后一个元素
                    list.add(1);
                }
                stack.add(list);
                m++;
            }
            int size= stack.size();
            /*for(int i=0;i<size;i++){
                System.out.println(stack.get(i));
            }*/
            for ( LinkedList<Integer> l:stack) {
                for(int i=0;i<l.size();i++){
                    System.out.printf("%5d",l.get(i));
                }
                System.out.println();
            }
        }
    }






    //单词搜索
    public static void main(String[] args) {
        String[] board={"XYZE","SFZS","XDEE"};
        String word="SEE";
        System.out.println(exist(board, word));
    }
    public static  boolean exist (String[] board, String word) {
        // write code here
        /*ArrayList<TreeMap<Character,Boolean>> list=new ArrayList<>();
        for (String s:board) {
            for(int i=0;i<s.length();i++){
                TreeMap<Character,Boolean> node=new TreeMap<>();
                node.put(s.charAt(i),false);
                list.add(node);
            }
        }*/
        int i=0;

        int n=0;
        int k=0;
        // 一个用来记录行一个记录行的列
        int[] a = new int[]{-1,-1,-1,-1,-1,-1,};
        int[] b=new int[]{-1,-1,-1,-1,-1};
        for(;i< board.length;i++){
            String str=board[i];
            int j=0;
            for (;j< str.length();j++){
                if(str.charAt(j) == word.charAt(k) ){
                    a[n]=i;
                    b[n]=j;
                    n++;
                }
            }
        }
        k++;
        i=0;
        int j=0;
        boolean b1=false;
        while(k != word.length()){
            b1=false;
            if(b[j]+1<board[a[i]].length()){
                if(board[a[i]].charAt(b[j]+1) == word.charAt(k)){
                    k++;
                    b1=true;
                    b[j]+=1;
                    continue;
                }
            }
            if(b[j]-1>=0){
                if(board[a[i]].charAt(b[j]-1) == word.charAt(k)){
                    k++;
                    b1=true;
                    b[j]-=1;
                    continue;
                }
            }
            if(a[i]+1<board.length){
                if(board[a[i]+1].charAt(b[j]) == word.charAt(k)){
                    k++;
                    b1=true;
                    a[i]+=i;
                    continue;
                }
            }
            if(a[i]-1>=0){
                if(board[a[i]-1].charAt(b[j]) == word.charAt(k)){
                    k++;
                    b1=true;
                    a[i]-=i;
                    continue;
                }
            }
            // 这个是属于出现了多次相同字符的情况
            if(b1== false && a[i]!=-1 ){
                i++;
                j++;
            }
            if(b1=false && a[i]==-1){
                return false;
            }
        }
        if(k == word.length() && b1==true){
            return true;
        }
        return false;
    }



    // 斐波那契数列
    public static void main01(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextInt()) { // 注意 while 处理多个 case
            int n = in.nextInt();
            if(n==1){
                System.out.println(0);
            }else{
                Stack<Integer> stack=new Stack<>();
                stack.add(1);
                stack.add(1);
                int m=0;
                while(stack.peek()<n){
                    int i=stack.pop();
                    int sum=stack.peek()+i;
                    stack.add(i);
                    if(sum>n){
                        m=sum;
                        break;
                    }
                    stack.add(sum);
                }
                int num=m-n;
                int num2=n- stack.peek();
                if(num>num2){
                    System.out.println(num2);
                }else{
                    System.out.println(num);
                }
            }

        }
    }
}
